package com.lc.type;

import com.lc.type.impl.IntegerTypeHandler;
import com.lc.type.impl.StringTypeHandler;

import java.util.HashMap;
import java.util.Map;

public class TypeHandlerRegistry {

    private static Map<Class<?>, TypeHandler> typeHandlerMap = new HashMap<>();

    public TypeHandlerRegistry() {
        IntegerTypeHandler integerTypeHandler = new IntegerTypeHandler();
        StringTypeHandler stringTypeHandler = new StringTypeHandler();
        typeHandlerMap.put(int.class, integerTypeHandler);
        typeHandlerMap.put(Integer.class, integerTypeHandler);
        typeHandlerMap.put(String.class, stringTypeHandler);
    }

    public static TypeHandler findTypeHandler(Class<?> property) {
        return typeHandlerMap.get(property);
    }

    public static void main(String[] args) {
        TypeHandlerRegistry typeHandlerRegistry = new TypeHandlerRegistry();
        TypeHandler typeHandler = typeHandlerRegistry.findTypeHandler(String.class);
        System.out.println("res: " + typeHandler);
    }


}
